<?php
namespace app\service;
use think\facade\Log;
class RecordLog {

    /*
     * 写入日志
     * 
     */
    public static function recordLog($content, $type = 'info', $force = false) {
        if (is_array($content)) {
            $content = json_encode($content);
        }
        $config = config('log.');
        $config['close'] = false;
        Log::init($config);
        Log::write($content."\r\n ", $type, $force);
        return true;
    }
	
	/*
     * 写入日志
     * 
     */
    public static function saveLog($content, $path = '') {
		if($path == ''){
			self::recordLog($content);
		}
		if (!is_dir($path)) {
            createDir($path);
            chmod($path, 0777);
        }
		$fp = @fopen($path, 'ab+');
		if (is_array($content)) {
            $content = json_encode($content);
        }
        if ($fp) {
            fwrite($fp, $content);
            fclose($fp);
        }
        return $path;
    }
}